class AdminController < ApplicationController

# Metodo para autenticar user
  def login
    if request.post?
      user = User.authenticate(params[:login], params[:password])
      if user
        session[:user_id] = user.id
        redirect_to(:controller => "home", :action => "index")
      else
        flash.now[:notice] = "Combinacion de usuario/contrasena invalida."
      end
    end
  end
  

# Metodo para cerrar session  
  def logout
    session[:user_id] = nil
    flash[:notice] = "Cesion cerrada"
    redirect_to(:action => "login")
  end
  

  
  def index
	@total_users = User.count
  end

# Panel de control con datos de usuario y de pago del usuario en sesion activa
  def panel
  	@userinfo = User.find_by_id(session[:user_id])
  	@paymethod = Paymethod.find_all_by_user_idf(session[:user_id])
  end
  
end

